#include "Failure.h"
#include <sstream>

namespace MockItNow
{

namespace
{
	const FunctionInfo* g_failureContext = NULL;
}

void SetFailureContext(const FunctionInfo* info)
{
	g_failureContext = info;
}

void ReportFailure(const std::string& message)
{
	if (g_failureContext == NULL)
		throw FailureException(message.c_str());

	std::stringstream stream;
	stream << "[" << g_failureContext->name << "] " << message;

	throw FailureException(stream.str().c_str());
}

}
